const app=getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        data:"",
        weather:"",
        text:""
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that=this
        this.setData({date:options.date})
        console.log(options.date)
        console.log(this.data.date)
           
              wx.request({
                url: 'https://wx.xxmtcds.top:2333/user/record/'+this.data.date,
                header:{
                  'authorization':app.globalData.token
                },
                
                success:function(res){
                    console.log(res)
                  that.setData({
                    content:res.data[0].record_content,
                    date:res.data[0].record_date,
                    mood:res.data[0].record_mood,
                    url:res.data[0].record_voice_url,
                    weather:res.data[0].record_weather
                  })
                }
              })
            
          
    },
    play(){
        this.innerAudioContext =  wx.createInnerAudioContext()
        wx.downloadFile({
            url: this.data.url, 
            success:(res)=> {
               
               if (res.statusCode === 200) {
                   
                   this.innerAudioContext.src = res.tempFilePath;
                   this.innerAudioContext.play()
                   
                  
                    
                
               }
            }
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let style=wx.getStorageSync('style')
        if(style!=''){
            this.setData({
                contentStyle:wx.getStorageSync('style')
            })
        }else{
            this.setData({
                contentStyle:'https://pic.imgdb.cn/item/6199ad962ab3f51d91e21dd0.jpg'
            })
        }
        let children=wx.getStorageSync('children')
        if(children!==''){
            this.setData({
                children:wx.getStorageSync('children')
            })
        }else{
            this.setData({
                children:'https://pic.imgdb.cn/item/6199ab9b2ab3f51d91e171d6.png'
            })
        }
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})